//
//  ThirdBarViewController.m
//  JiJinFinance
//
//  Created by 李东晓 on 15/12/1.
//  Copyright © 2015年 LiDongXiao. All rights reserved.
//
#import "ThirdBarViewController.h"
#import "ThirdTableViewCell.h"
@interface ThirdBarViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView * thirdTableView;
}
@end
//static NSString * cellId = @"ThirdTableViewCell";
@implementation ThirdBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setTitle:@"活动"];
    
    //自定义Title的大小
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    
    thirdTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kUIScreenWidth, kUIScreenHeight) style:UITableViewStyleGrouped];
    
    [thirdTableView setDataSource:self];
    
    [thirdTableView setDelegate:self];
    
    [self.view addSubview:thirdTableView];
    
    //    [thirdTableView registerNib:[UINib nibWithNibName:cellId bundle:[NSBundle mainBundle]] forCellReuseIdentifier:cellId];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *str = @"如果你无法简洁的表达你的想法，那只说明你还不够了解它。";
    
    CGFloat height = [self heightForString:str];
    return 103;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
-(UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString * cellId = @"cell";
    
    ThirdTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    
    if (cell == NO) {
        cell = [[ThirdTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
    }
    return cell;
}


#pragma mark - 计算字符串高度
-(CGFloat)heightForString:(NSString *)str{
    UILabel *label = [UILabel alloc];
    label.backgroundColor = [UIColor whiteColor];
    label.text = str;
    label.font = [UIFont systemFontOfSize:15];
    CGSize labelSize = CGSizeMake(kUIScreenWidth - 110, 0);
    NSDictionary *attribute = @{NSFontAttributeName:label.font};
    
    CGRect rect = [label.text boundingRectWithSize:labelSize options:NSStringDrawingTruncatesLastVisibleLine |
                   NSStringDrawingUsesLineFragmentOrigin |
                   NSStringDrawingUsesFontLeading attributes:attribute context:nil];
    
    return rect.size.height;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
